package com.lineage.data.item_etcitem.teleport;

import com.add.AutoAttackUpdateNew;
import com.lineage.data.executor.ItemExecutor;
import com.lineage.server.Shutdown;
import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.L1Trade;
import com.lineage.server.serverpackets.S_SystemMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import com.lineage.server.timecontroller.server.ServerRestartTimer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Hang_fu_Point extends ItemExecutor {
  private static final Log _log = LogFactory.getLog(Hang_fu_Point.class);
  
  public static ItemExecutor get() {
    return new Hang_fu_Point();
  }
  
  public void execute(int[] data, L1PcInstance pc, L1ItemInstance item) {
    if (item == null)
      return; 
    if (pc == null)
      return; 
    if (pc.isPrivateShop())
      return; 
    if (pc.isFishing())
      return; 
    if (ServerRestartTimer.isRtartTime()) {
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("伺服器即将关机 无法使用"));
      return;
    } 
    if (Shutdown.SHUTDOWN) {
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("伺服器即将关机 无法使用"));
      return;
    } 
    if (pc.getTradeID() != 0) {
      L1Trade trade = new L1Trade();
      trade.tradeCancel(pc);
    } 
    int time = pc.get_other().get_Auto_Points();
    if (time > 0) {
      AutoAttackUpdateNew.getInstance().guaji(pc);
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("您的可挂机时间剩余" + 
            String.valueOf(time / 60) + "分钟"));
    } else {
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("挂机时间不足故无法挂机"));
    } 
  }
}
